<?php




function bugcheck($object) {
   $text=$object->getMessage();
    echo "<script type=\"text/javascript\">bugcheckAlert('$text')</script>";
    $timestamp=date(DATE_RSS);


    if ($log) {
        $errlogHandle = fopen('errlog.php', 'a', false);
        flock($errlogHandle, LOCK_EX);
        if (!file_exists('errlog.php')||filesize('errlog.php')==0){
            $hdrtext='<?php die(); //THIS IS A HEADER USED TO AVIOD REMOTELY OBTAINING SENSITIVE DATA FROM A STACKTRACE. ?>';
            fwrite($errlogHandle, $hdrtext);
            
        }




        
        
        zfwrite($errlogHandle,$timestamp."\t".$_SERVER['QUERY_STRING']."\t".$_SERVER['REMOTE_ADDR']."\t".$text."\t"."backtrace".time().".txt \r\n" );
        flock($errlogHandle, LOCK_UN);   
        fclose($errlogHandle);
    }
    if ($backtrace){
        $backtracehandle = fopen('backtrace'.$timestamp.'.txt', 'w', false);
        flock($backtracehandle, LOCK_EX);
        fwrite($backtracehandle,'<?php die(); //THIS IS A HEADER USED TO AVIOD REMOTELY OBTAINING SENSITIVE DATA FROM A STACKTRACE. ?>'."\r\n".debug_backtrace());
        
        
    }
}


function bugcheck2($errno, $errstr, $errfile, $errline){
    $bugcheckmsg="$errno : $errstr in $errfile in line $errline)";
    bugcheck($bugcheckmsg);
    return false;
}


?>
